From 70efcfeaa0603415dd992cb662d8efb960e6e49a Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Tue, 26 Sep 2023 15:54:28 +0200 Subject: refactor(routes): replace hardcoded routes with constants It makes it easier to change a route if needed and it avoid typo mistakes. I also refactored a bit the concerned files to be complient with the new ESlint config. However, I should rewrite the pages to reduce the number of statements. --- src/pages/thematique/[slug].tsx | 46 ++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'src/pages/thematique/[slug].tsx') diff --git a/src/pages/thematique/[slug].tsx b/src/pages/thematique/[slug].tsx index 7712fff..cf610c7 100644 --- a/src/pages/thematique/[slug].tsx +++ b/src/pages/thematique/[slug].tsx @@ -1,16 +1,17 @@ -import { GetStaticPaths, GetStaticProps } from 'next'; +/* eslint-disable max-statements */ +import type { ParsedUrlQuery } from 'querystring'; +import type { GetStaticPaths, GetStaticProps } from 'next'; import Head from 'next/head'; import { useRouter } from 'next/router'; import Script from 'next/script'; -import { ParsedUrlQuery } from 'querystring'; import { useIntl } from 'react-intl'; import { getLayout, Heading, LinksListWidget, PageLayout, - type PageLayoutProps, PostsList, + type MetaData, } from '../../components'; import { getAllThematicsSlugs, @@ -18,11 +19,8 @@ import { getThematicsPreview, getTotalThematics, } from '../../services/graphql'; -import { - type NextPageWithLayout, - type PageLink, - type Thematic, -} from '../../types'; +import type { NextPageWithLayout, PageLink, Thematic } from '../../types'; +import { ROUTES } from '../../utils/constants'; import { getLinksListItems, getPageLinkFromRawData, @@ -49,10 +47,10 @@ const ThematicPage: NextPageWithLayout = ({ const intl = useIntl(); const { items: breadcrumbItems, schema: breadcrumbSchema } = useBreadcrumb({ title, - url: `/thematique/${slug}`, + url: `${ROUTES.THEMATICS.INDEX}/${slug}`, }); - const headerMeta: PageLayoutProps['headerMeta'] = { + const headerMeta: MetaData = { publication: { date: dates.publication }, update: dates.update ? { date: dates.update } : undefined, total: articles ? articles.length : undefined, @@ -89,20 +87,26 @@ const ThematicPage: NextPageWithLayout = ({ description: 'ThematicPage: related topics list widget title', id: '/42Z0z', }); + const pageUrl = `${website.url}${asPath}`; + const postsListBaseUrl = `${ROUTES.THEMATICS.INDEX}/page/`; return ( <> {seo.title} + {/*eslint-disable-next-line react/jsx-no-literals -- Name allowed */} - + + {/*eslint-disable-next-line react/jsx-no-literals -- Content allowed */}